/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.usc.cs576.lib;

import edu.usc.cs576.lib.mediaObject.Audio;
import edu.usc.cs576.lib.mediaObject.Image;
import edu.usc.cs576.lib.mediaObject.Video;

/**
 * This class is using factory design pattern to generate the media object
 * @author haoxu
 */
public class MediaFactory {

    private static MediaFactory factory;

    private MediaFactory() {
    }

    public static MediaFactory getInstance() {
        if (factory == null) {
            factory = new MediaFactory();
        }
        return factory;
    }

    public Video readVideo(String filepath, String filename, int width, int height) {
        Video video = new Video();

        video.setFilepath(filepath);
        video.setFilename(filename);
        video.setWidth(width);
        video.setHeight(height);
//        video.load();
        return video;
    }

    public Audio readAudio(String filepath, String name, int AUDIO_TYPE_WAV) {
        Audio audio = new Audio();

        audio.setFilename(name);
        audio.setFilepath(filepath);
        audio.load();
        return audio;
    }

    public Image readImage(String filepath) {
        Image image = new Image();
        image.setFilepath(filepath);
        return image;
    }
}
